-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: head and tail not dropping groups with nan #45102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
doc/source/whatsnew/v1.4.0.rst
Outdated
@@ -894,6 +894,7 @@ Groupby/resample/rolling | |||
- Bug in :meth:`GroupBy.nth` failing on ``axis=1`` (:issue:`43926`) | |||
- Fixed bug in :meth:`Series.rolling` and :meth:`DataFrame.rolling` not respecting right bound on centered datetime-like windows, if the index contain duplicates (:issue:`3944`) | |||
- Bug in :meth:`Series.rolling` and :meth:`DataFrame.rolling` when using a :class:`pandas.api.indexers.BaseIndexer` subclass that returned unequal start and end arrays would segfault instead of raising a ``ValueError`` (:issue:`44470`) | |||
- Bug in :meth:`GroupBy.head` and :meth:`GroupBy.tail` no dropping groups with ``NaN`` when ``dropna=True`` (:issue:`45089`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no -> not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx
|
||
result = df.groupby(["X", "Y"]).tail(n=1) | ||
tm.assert_frame_equal(result, expected) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you test nth here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
what does this mean |
Adjusting the mask for the dropna flag in a dedicated function, because the place I put this is a bit awkward |
We could also create a specific function for this.
Also that nth respects
as_index
while it is ignored byhead
andtail
looks inconsistent